package com.zelin.search.controller;

import com.zelin.search.entity.ItemVo;
import com.zelin.search.service.ItemSearchService;
import net.bytebuddy.asm.Advice;
import org.elasticsearch.search.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Map;

/**
 * ------------------------------
 * 功能：
 * 作者：WF
 * 微信：hbxfwf13590332912
 * 创建时间：2021/11/2-15:17
 * ------------------------------
 */
@Controller
public class SearchController {

    @Autowired
    private ItemSearchService searchService;

    //1. 开始进行条件查询
    @GetMapping({"/","/search.html"})
    public String search(Model model, ItemVo itemVo) {
        //1.1 根据前端传入的参数进行查询
        Map<String, Object> resultMap = searchService.search(itemVo);
        //1.2 将查询结果放到model中
        model.addAttribute("resultMap",resultMap);
        model.addAttribute("vo",itemVo);
        return "search";
    }
}
